package com.bx.scala.ObjextFoundation06

/**
 * 演示 对象apply方法
 */



class DemoApplyObject(val id:Int, val name : String) {
  println("This is class DemoApplyObject.")
}

object DemoApplyObject {

  def apply(id: Int, name: String): DemoApplyObject = {
    println("Applied in object DemoApplyObject")
    new DemoApplyObject(id, name)
  }

  def main(args: Array[String]): Unit = {
  val demo02 = new DemoApplyObject(1,"simon")
  println(s"id: ${demo02.id}, name: ${demo02.name}")
    println ("#"*20)
    val demoApply = DemoApplyObject(2, "appplied")
    println(s"id: ${demoApply.id}, name: ${demoApply.name}")
  }

}